package FirstProject;
//网虫套餐
public class NetPackage extends ServicePackage implements NetService{
    public int flow=3072;
    public double price=68;
    public NetPackage(double price) {
        super(price);
    }
    public NetPackage(int flow,double price) {
        super(58);
        this.flow = flow;
        this.price = price;
    }

    public int getFlow() {
        return flow;
    }

    public void setFlow(int flow) {
        this.flow = flow;
    }
    @Override
    public void showInfo() {
        System.out.println("网虫套餐" +price+"元/月"+ ",流量:" +flow+"MB/月");
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public int netPlay(int flow, MobileCard card) {
        int extra=0;
        if(flow<=this.flow){
            this.flow-=flow;
        }else{
            extra=flow-this.flow;
            this.flow=0;
            card.consumeAmount+=extra*0.1;
        }
        card.realFlow+=flow;
        return extra;
    }
}
interface NetService{
    int netPlay(int flow,MobileCard card);
}